<template>
  <div>
    <ConTitle :info="topTitle"/>
    <el-table :data="accountList" style="width: 100%">
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="account" label="子账号"></el-table-column>
      <el-table-column prop="username" label="用户名称"></el-table-column>
      <el-table-column prop="type" label="类型">
        <template slot-scope="scope">
          {{ scope.row.type|onlineType }}
        </template>
      </el-table-column>
      <el-table-column prop="cTime" label="创建时间">
        <template slot-scope="scope">
          {{ scope.row.cTime|format }}
        </template>
      </el-table-column>
      <el-table-column prop="uTime" label="更新时间">
        <template slot-scope="scope">
          {{ scope.row.uTime|format }}
        </template>
      </el-table-column>
      <el-table-column prop="desc" label="描述"></el-table-column>



      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">重命名</el-button>
          <el-button type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import ConTitle from "@/components/ConTitle.vue";
import {$accountList} from "@/api/index.js";

export default {
  name: "accountlist",
  components: {
    ConTitle,
  },
  data() {
    return {
      topTitle: {
        type: "子账号",
        text: "子账号列表",
        msg: "展示当前组织下的所有子账号，可修改子账号信息或删除子账号。",
      },
      accountList: [],
      total: 0,
    }
  },
    filters: {
      onlineType(value) {
        return value==1? "超级管理员" : "观察员";
      },
      format(value) {
        function addZero(num) {
          return num >= 10 ? num : "0" + num;
        }

        var time = new Date(value);
        var y = time.getFullYear();
        var m = addZero(time.getMonth() + 1);
        var d = addZero(time.getDate());
        return `${y}-${m}-${d}`;
      },
    },
  created() {
    this.getAccountList();
  },
  methods: {
    //获取列表数据的函数
    getAccountList() {
      $accountList(this.query).then((res) => {
        console.log(res);
        this.accountList = res.data.data;
        this.total = res.data.total;
      });
    },
  }
}
</script>

<style scoped>

</style>